﻿using System;
using System.Collections.Generic;
using System.Text;
using MVPlan.Engine.Gases;

namespace MVPlan.Engine
{
    public class Util
    {
        public static double CalcCeiling(double fO2)
        {
            return CalcMod(fO2, Prefs.Current.PPO2Min);
        }

        public static double CalcMod(double fO2, double ppO2)
        {
            return (ppO2 / fO2 * Prefs.Current.PConversion) - Prefs.Current.PConversion;
        }

        public static double CalcMod(double fO2)
        {
            return CalcMod(fO2, Prefs.Current.PPO2Max);
        }

        public static double CalcEND(Gas g)
        {
            return CalcEND(g, g.MOD);
        }

        public static double CalcEND(Gas g, double depth)
        {
            double pAbsolute = depth + Prefs.Current.PAmb; // msw (fsw)
            double ppN2Inspired;


            ppN2Inspired = (pAbsolute) * g.FN2;

            double end = ppN2Inspired / 0.79 - Prefs.Current.PAmb;

            return end > 0 ? end : 0; // Only return positive numbers.
        }
    }
}
